<?php 
namespace Home\Model;
use Think\Model\ViewModel;

/**
 * 查找用户站内信
 * @author Cifang
 *
 */
//查找当前用户的相关站内信的sql语句
/*  $m = "select m.id,u.username fromname,uu.username toname
 from tbl_message m
 left join tbl_user u on m.fromuid=u.id
 left join tbl_user uu on m.touid=uu.id"; */
 
class InternalMsgViewModel extends ViewModel {
    protected $viewFields = array(
		'message' => array(
			'id', 'title', 'content', 'sendTime', 'status',
			'_type' => 'LEFT'
			),
		'user' => array(
		    'username'=>'fromname',
			'_on' => 'message.fromuid = user.id'
			),
        'user2' => array(
            '_table' => 'tbl_user',
            '_as'=>'user2', 
            'username'=>'toname',
            '_on' => 'message.touid = user2.id'
            )
		);
}
